<template>
  <div data-v-522f1083 class="ucenter-home-wrapper wrapper">
    <news-page-header>个人中心</news-page-header>

    <div class="home-userInfo-board">
      <div>
        <div class="home-avatar avatar-wrapper big">
          <img :src="require('@/assets/img/icon/ic_home.png')" class="avatar" />
        </div>
      </div>
      <span class="home-username">
        搜狐用户
        <span v-text="sohuUsername"></span>
      </span>
      <a href="#" class>
        <div class="home-gold-beans">
          <div class="goldbeans-wrapper">
            <i class="icon-goldbeans"></i>
          </div>
          <span class="jd-sum">
            <span class="amount">0</span> 金豆
          </span>
        </div>
      </a>
    </div>
    <div data-spm="funlist1" class="header-menu-list">
      <a href="#" class="header-menu-item" @click="toMyLike">
        <div class="glyph glyph-like-sb">
          <i class="mylike myicon"></i>
        </div>
        <div class="menu-title">我的订阅</div>
      </a>
      <!---->
      <a href="#" class="header-menu-item" @click="toMyComment">
        <div class="glyph glyph-ic-comment-new">
          <i class="mycomment myicon"></i>
        </div>
        <div class="menu-title">我的评论</div>
      </a>
      <!---->
      <a href="#" class="header-menu-item" @click="toMyReply">
        <div class="glyph glyph-ic-reply-n">
          <i class="myreply myicon"></i>
        </div>
        <div class="menu-title">回复我的</div>
      </a>
      <!---->
      <a href="#" class="header-menu-item" @click="toMyDiscount">
        <div class="glyph glyph-ic-discount">
          <i class="mydiscount myicon"></i>
        </div>
        <div class="menu-title">我的优惠</div>
      </a>
      <!---->
    </div>
    <!---->
    <div data-spm="funlist2" class="menu-list-wrapper menu-list-home">
      <a href="#">
        <div class="menu-wrapper">
          <!---->
          <div class="menu-content">
            <div class="menu-text">搜狐金彩</div>
            <div class="menu-enter glyph glyph-left mirror">
              <i class="glyph-right myicon"></i>
            </div>
          </div>
        </div>
      </a>
      <a href="#">
        <div class="menu-wrapper">
          <!---->
          <div class="menu-content">
            <div class="menu-text">小说书城</div>
            <div class="menu-enter glyph glyph-left mirror">
              <i class="glyph-right myicon"></i>
            </div>
          </div>
        </div>
      </a>
      <a href="#">
        <div class="menu-wrapper">
          <!---->
          <div class="menu-content">
            <div class="menu-text">我的订单</div>
            <!---->
            <!---->
            <div class="menu-enter glyph glyph-left mirror">
              <i class="glyph-right myicon"></i>
            </div>
          </div>
        </div>
      </a>
      <!---->
      <a href="#">
        <div class="menu-wrapper">
          <!---->
          <div class="menu-content">
            <div class="menu-text">系统通知</div>
            <!---->
            <!---->
            <div class="menu-enter glyph glyph-left mirror">
              <i class="glyph-right myicon"></i>
            </div>
          </div>
        </div>
      </a>
      <a href="#" @click="toMyNotice">
        <div class="menu-wrapper">
          <!---->
          <div class="menu-content">
            <div class="menu-text">设置</div>
            <!---->
            <!---->
            <div class="menu-enter glyph glyph-left mirror">
              <i class="glyph-right myicon"></i>
            </div>
          </div>
        </div>
      </a>
    </div>
  </div>
</template>

<script>
import "../../assets/css/registerCss/userCenter.css";
import newsPageHeader from "../news/newsPageHeader";

export default {
  data() {
    return {
      sohuUsername: ""
    };
  },
  components: {
    newsPageHeader
  },
  methods: {
    toMain() {
      this.$router.push({ name: "main" });
    },
    toMyLike() {
      this.$router.push({ name: "myLike" });
    },
    toMyComment() {
      this.$router.push({ name: "myComment" });
    },
    toMyReply() {
      this.$router.push({ name: "myReply" });
    },
    toMyDiscount() {
      this.$router.push({ name: "myDiscount" });
    },
    toMyNotice() {
      this.$router.push({ name: "myNotice" });
    }
  },
  computed: {},
  watch: {},
  async created() {
    let token = localStorage.getItem("sohuToken");
    
    if (token) {
      //有token：登陆了，验证token
      let { data } = await this.$axios.get("http://localhost:9394/users/verify", {
        params: {
          token
        }
      });
      // window.console.log(data);
      
      if (data.type) {
        //成功
        let sohuUsername = localStorage.getItem("sohuUsername");
        this.sohuUsername = sohuUsername;
      } else {
        //失败
         localStorage.removeItem("sohuToken");
            localStorage.removeItem("sohuUsername");
        this.$router.push({name:'login'})
      }
    } else {
      this.$router.push({name:'login'})
    }
  },
  mounted() {}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
